package com.epoint.mobileoa.personalized.epointcompany.bizlogic;




import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.epoint.mobileoa.R;
import com.epoint.mobileoa.bizlogic.PersonalMainView;
import com.epoint.mobileoa.bizlogic.SuperView;
import com.epoint.mobileoa.bizlogic.icon.IconInfo.OnClickListener;
import com.epoint.mobileoa.personalized.epointcompany.ui.ChuChaijihuaList;
import com.epoint.mobileoa.personalized.epointcompany.ui.gzrz.GzrzMainView;
import com.epoint.mobileoa.personalized.epointcompany.ui.kaoqing.KaoQingView;

import com.epoint.mobileoa.tools.EpointDialog;
import com.epoint.mobileoa.tools.dialog.SuperDialog;
import com.epoint.mobileoa.ui.attachmanager.AttachManagerView;
import com.epoint.mobileoa.ui.contacts.ContactsView;
import com.epoint.mobileoa.ui.ds.DSView;
import com.epoint.mobileoa.ui.help.HelpView;
import com.epoint.mobileoa.ui.infopub.InformationPubView;
import com.epoint.mobileoa.ui.mail.MailMain;
import com.epoint.mobileoa.ui.main.MainView;
import com.epoint.mobileoa.ui.notice.NoticeListView;
import com.epoint.mobileoa.ui.sysconfig.SysconfigView;
import com.epoint.mobileoa.ui.todolist.TodolistView;
import com.epoint.mobileoa.ui.toolview.New9gg;
import com.epoint.mobileoa.ui.update.UpdateView;

/**
 * @author liyc
 * @time 2012-2-20 下午5:23:24
 * @annotation 新点公司个性化主界面
 */
public class EpointCompany_Personalized extends PersonalMainView{

	private SuperView sv;

	public EpointCompany_Personalized(SuperView sv){
		this.sv = sv;
	}

	private String[] titles = new String[] { 
			"待办事宜","公务邮件", "通知公告",
			"工作日志","出差计划", "信息发布",
			"通讯录","附件管理","数据同步",
			"考勤签到","系统设置", "软件更新" 
	};

	private int[] imgs = new int[] { R.drawable.dbsy, R.drawable.gwyj, R.drawable.tzgg,
			R.drawable.img_epoint_gzrz,R.drawable.img_epoint_ccdj3,R.drawable.xxfb,
			R.drawable.txl, R.drawable.fjgl, R.drawable.sjtb,
			R.drawable.kqqd, R.drawable.xtsz, R.drawable.rjgx };

	private Class<?>[] intentViews = new Class[]{
			TodolistView.class,MailMain.class,NoticeListView.class,
			null,ChuChaijihuaList.class,InformationPubView.class,
			ContactsView.class,AttachManagerView.class,DSView.class,
			KaoQingView.class,SysconfigView.class,UpdateView.class
	};

	@Override
	public int[] getImgs() {
		return imgs;
	}

	@Override
	public String[] getTitles() {
		return titles;
	}

	public OnClickListener[] getOnClickListener(){

		OnClickListener[] o = new OnClickListener[titles.length];

		o[3] = new OnClickListener() {
			@Override
			public void onClick() {

				String[] classesName = new String[]{
						"com.epoint.mobileoa.personalized.epointcompany.ui.PersonalRiziListView",
						"com.epoint.mobileoa.personalized.epointcompany.ui.gzrz.RizhiShenHeListView"
				};

				new New9gg(sv, 
						"个人日志",
						new String[]{"我的日志","日志审核"}, 
						new int[]{R.drawable.img_wdrz, R.drawable.img_rzsh},
						classesName);
			}
		};
		return o;
	}

	@Override
	public int[] getPositions() {
		return new int[]{1,2,3,4,5,6,7,8,9,10,11,12};
	}

	@Override
	public Class[] getIntentViews() {
		return intentViews;
	}

	public void onCreateOptionsMenu(Menu menu){
		menu.add(0, 1, 1, "退出程序").setIcon(R.drawable.menu_quit);
		menu.add(0, 2, 2, "注销登录").setIcon(R.drawable.menu_zhuxiao);
		menu.add(0, 3, 3, "帮助说明").setIcon(R.drawable.menu_help);
	}

	public void OnOptionsItemSelected(MenuItem item){
		switch(item.getItemId()){
		case 1:
			MainView.quitApp(sv);
			break;
		case 2:
			/*MainView.epointDialog = EpointDialog.getDialog(
					sv, 
					"您要注销程序吗？", 
					2, 
					new View.OnClickListener() {
						@Override
						public void onClick(View v) {
							MainView.quitLogin(sv);
							MainView.epointDialog.dismiss();
						}
					});
			MainView.epointDialog.show();*/
			
			final SuperDialog sd = new SuperDialog(sv);
			sd.setPositiveButton("确定", new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					MainView.quitLogin(sv);
					sd.dismiss();
				}
			})
			.setMessage("您要注销程序吗？")
			.setNegativeButton("取消", null)
			.show();
			break;
		case 3:
			Intent it_help = new Intent(sv, HelpView.class);
			sv.startActivity(it_help);
			break;
		}
	}
}
